package com.prs.crm.domain.doc;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.prs.crm.domain.Attachment;
import com.prs.crm.domain.FlowCodeEntity;
import com.prs.crm.domain.hr.Person;
import com.prs.crm.domain.sys.Code;

@Entity
@Table(name="doc_deptdoc")
public class DeptDoc extends FlowCodeEntity {

	private static final long serialVersionUID = 4789805216322410885L;
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	@ManyToOne
	private DeptDocType type;
	private String name;
	private String deptDoccode;
	@Lob
	private String remark;
	@ManyToOne(fetch=FetchType.LAZY,cascade=CascadeType.ALL)
	private FileType fileType;
	
//	@OneToOne(fetch=FetchType.LAZY,mappedBy="deptdoc")
//	private Code code;
//	
//	
//	
//public Code getCode() {
//		return code;
//	}
//	public void setCode(Code code) {
//		this.code = code;
//	}
	//	@JoinTable(name="doc_deptdoc_owner",
//			joinColumns = {@JoinColumn(name="doc_deptdoc_id")},
//			inverseJoinColumns = {@JoinColumn(name="person_id")}
//	)
	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.MERGE,CascadeType.PERSIST},targetEntity=Person.class)
	@JoinColumn(name="person_id")
	@OrderBy
	private Person owner;
	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL})
	private Attachment attach;
	private String state;
	@OneToMany(fetch=FetchType.LAZY,mappedBy="deptDoc",cascade={CascadeType.REMOVE})
	private Set<ShareDeptDoc> shares;
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public DeptDocType getType() {
		return type;
	}
	public void setType(DeptDocType type) {
		this.type = type;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public String getDeptDoccode() {
		return deptDoccode;
	}
	public void setDeptDoccode(String deptDoccode) {
		this.deptDoccode = deptDoccode;
	}
	public static long getSerialVersionUID() {
		return serialVersionUID;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public Attachment getAttach() {
		return attach;
	}
	public void setAttach(Attachment attach) {
		this.attach = attach;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public Set<ShareDeptDoc> getShares() {
		return shares;
	}
	public void setShares(Set<ShareDeptDoc> shares) {
		this.shares = shares;
	}
	public FileType getFileType() {
		return fileType;
	}
	public void setFileType(FileType fileType) {
		this.fileType = fileType;
	}
	public Person getOwner() {
		return owner;
	}
	public void setOwner(Person owner) {
		this.owner = owner;
	}
	
	
	
	
}
